package edu.uic.cs.i422.s2011.team4;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

public class ItemsAdapter extends BaseAdapter {
    private Context mContext;
    private Integer[] mItemsResourcesIds;
    private Integer[] mItemsStringsIds;

    /**
     * The Items Adapter
     * @param c Android's context
     * @param i Image's Resources Id's
     * @param s String's Resources Id's
     */
    public ItemsAdapter(Context c, Integer[] i, Integer[] s) {
    	mContext = c;
    	mItemsResourcesIds = i;
    	mItemsStringsIds = s;
    }

    public int getCount() {
        return mItemsResourcesIds.length;
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return position;
    }

    /**
     * Create a new "Items" using the setting_item.xml template for each item
     * referenced by the Adapter
     */
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {        
    	View view;
    	/**
    	 * Set Layout parameters
    	 */        	 
        view = LayoutInflater.from(mContext).inflate(R.layout.setting_item, parent, false);
        view.setLayoutParams(new GridView.LayoutParams(140, 140));
        
        /**
         * Set the Text
         */
        TextView text = (TextView) view.findViewById(R.id.settingItemText);
        text.setText(mItemsStringsIds[position]);
        
        /**
         * Select the indicator and set it up
         */
        ImageView indicator = (ImageView) view.findViewById(R.id.settingItemIndicator);
        indicator.setImageResource(R.drawable.squirrel_no);
    	
    	/**
    	 * Select the image and set it up
    	 */
        ImageView image = (ImageView) view.findViewById(R.id.settingItemImage);
        image.setImageResource(mItemsResourcesIds[position]);
        
        return view;
    }

   
}
